import {
    addmangerroom, // 添加教室接口
    mangerroom, // 获取全部教室
    mangerroomdelete,//删除教室接口
  } from '@/services/classmanagement'
  export default {
  
      namespace: 'classroom',
    
      state: {
        mangerroomList: [],
        addmangerroomList:{}
      },
    
      subscriptions: {
        setup({ dispatch, history }) {  // eslint-disable-line
          dispatch({
            type: 'mangerroom'
          })
        },
      },
    
      effects: {
        *mangerroom({ payload }, { call, put }) {  // eslint-disable-line
          const data = yield call(mangerroom)
          yield put({
            type: 'changeState',
            payload: {
              mangerroomList: data
            }
          })
        },
        *addmangerroom({ payload }, { call, put }) {
          yield call(addmangerroom,{room_text: payload})
        },
        *mangerroomdelete({ payload }, { call, put }){
          console.log(payload.room_id)
          const data = yield call(mangerroomdelete,{room_id:payload.room_id})
          console.log(data,'data2222222222222')
        }
      },
    
      reducers: {
        changeState(state, action) {
          return { ...state, ...action.payload };
        },
      },
    
    };
    